package com.shi.yoyoshop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shi.yoyoshop.bean.Admin;
import com.shi.yoyoshop.mapper.AdminMapper;
import com.shi.yoyoshop.service.AdminService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 20556
 * @description 针对表【admin】的数据库操作Service实现
 * @createDate 2024-01-05 18:52:32
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin>
        implements AdminService {

    @Resource
    private AdminMapper adminMapper;

    @Override
    public Admin getAdminByUsername(String username) {
        return adminMapper.selectOne(new LambdaQueryWrapper<Admin>()
                .select(Admin::getId, Admin::getUsername, Admin::getPassword)
                .eq(Admin::getUsername, username));
    }

    @Override
    public void updatePasswordById(String password, Integer id) {
        Admin admin = new Admin();
        admin.setId(id);
        admin.setPassword(password);
        adminMapper.updateById(admin);
    }
}




